package collections;


import java.util.ArrayList;
import java.util.Collections;

//班级有n个学生，要求被点到的学生不会再被点到，如果点完了，则开启第二轮
public class Test3 {
    public static void main(String[] args) {
        //创建集合
        ArrayList<String> list1 = new ArrayList<>();
        //添加元素
        Collections.addAll(list1,"沙耶松","帕姆","涵江","张天舒","范中航","文轩清","李德全","王国栋","张立伟",
                "君安肆","小叶榕","娜米玉","徐雅雯","许瑶");
        //临时集合，存储点过名的学生
        ArrayList<String> list2 = new ArrayList<>();
        //循环点名
        for (int i = 0; i < 5; i++) {
            //打乱元素
            Collections.shuffle(list1);
            //获得集合长度
            int count = list1.size();
            System.out.println("=========第" + (i+1)  + "次点名=========");
            for (int j = 0; j < count; j++) {
                String name = list1.remove(0);
                //将点到的名放入list2中
                list2.add(name);
                System.out.println(name);
            }
            list1.addAll(list2);
            list2.clear();
        }

    }
}
